<template>
  <div class="main-bg">
    <el-descriptions title="订单详情" :column="2"  border>
      <el-descriptions-item label="订单号">{{form.orderCode}}</el-descriptions-item>
      <el-descriptions-item label="下单时间">{{timestampToTime(form.createTime)}}</el-descriptions-item>
      <el-descriptions-item label="送货地址">{{form.buyAddress}}</el-descriptions-item>
      <el-descriptions-item label="订单总额">{{form.totalRealityMoney}}元</el-descriptions-item>
      <el-descriptions-item label="下单人">{{form.createName}}</el-descriptions-item>
    </el-descriptions>
    <el-button type="primary" style="float: right;margin-top: 10px;" >打印</el-button>
    <div class="container">
      <el-table
        :data="form.orderGoodsDtos"
        v-loading="loading"
        style="width: 100%"
      >
        <el-table-column
          prop="goodsCode"
          align="center"
          label="商品编号">
        </el-table-column>
        <el-table-column
          prop="goodsName"
          align="center"
          label="商品名">
        </el-table-column>
        <el-table-column
          prop="groupName"
          align="center"
          label="规格">
        </el-table-column>
        <el-table-column
          prop="discountsPrice"
          align="center"
          label="购买单价">
        </el-table-column>
        <el-table-column
          prop="totalAmount"
          align="center"
          label="数量">
        </el-table-column>
        <el-table-column
          prop="totalDiscountsPrice"
          align="center"
          label="总金额">
        </el-table-column>
        <el-table-column
          prop="totalDiscountsPrice"
          align="center"
          label="商品类型">
          <template slot-scope="scope">
            {{scope.row.goodsType==1301?'购买':'赠送'}}
          </template>
        </el-table-column>
        <el-table-column
          prop="remark"
          align="center"
          label="备注">
        </el-table-column>
      </el-table>
    </div>

  </div>
</template>

<script>
  import {getOrderDetails} from '@/api/order/order.js'
  export default {
    name: "orderDetail",
    data(){
      return{
        form:{},
        loading:true
      }
    },
    mounted(){
      console.log(this.$route.query.orderId)
      this.getList()
    },
    methods:{
      async getList(){
        let body={
          storeCoding:localStorage.getItem('storeCoding'),
          "orderId": this.$route.query.orderId
        }

        let res = await getOrderDetails({body})
        this.form=res.body
        this.loading=false
      },
      timestampToTime(timestamp) {
       var time = this.dayjs(timestamp).format("YYYY-MM-DD");
       // var date = new Date(timestamp);//时间戳为10位需*1000，时间戳为13位的话不需乘1000
       // var Y = date.getFullYear() + '-';
       // var M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
       // var D = date.getDate() + ' ';
       return time;
      },
      handleCurrentChange(val){
        this.pageNum=val
        this.getList()
      }
    },
  }
</script>

<style scoped>
  .titlebox{
    color:#20384D;
    font-size: 16px;
    display: flex;
    align-items: center;
    margin-bottom: 30px;
  }
  .titlebar{
    width: 4px;
    height: 16px;
    background: #035EBA;
    border-radius: 0 2px 2px 0;
    margin-right: 10px;
  }
  .titleline{
    flex: 1;
    height: 2px;
    background: #E6E9EE;
    margin-left: 20px;
  }
  .upload-tips{
    color: #999999;
    line-height: 20px;
  }
</style>
